In [1]:
import numpy as np
from matplotlib import pyplot as plt
from __future__ import division
from spacetime.CA_Simulators.CAs import *
from spacetime.Local_Measures.Local_Complexity import *
%matplotlib inline

Code for 0-wildcard tiling


In [2]:
def wildcard_tiling(x,t):
    '''
    Returns spacetime field of dimension (x,t) sampled from 0-wildcard tiling language.
    '''
    field = np.zeros((t,x), dtype=int)
    for i in xrange(t):
        for j in xrange(x):
            if i % 2 == 0 and j % 2 == 0:
                field[i,j] = np.random.choice([0,1])
            elif i % 2 == 1 and j % 2 == 1:
                field[i,j] = np.random.choice([0,1])
    
    return field

In [ ]:

Run machine inference on samples from this tiling


In [8]:
tiling_field = wildcard_tiling(600,600)

In [12]:
tiling_states = epsilon_field(tiling_field)
tiling_states.estimate_states(3,3,1, alpha = 0.05)
tiling_states.filter_data()

In [10]:
print tiling_states.number_of_states()


3

In [13]:
state_overlay_diagram(tiling_field, tiling_states.get_causal_field(), t_min = 10, t_max = 50, x_max = 40)



In [ ]:


In [6]:
print tiling_states.entropy_rate('forward')
print tiling_states.entropy_rate('right')
print tiling_states.entropy_rate('left')


0.68002562571
0.739440226292
0.739599303525

In [ ]:

rule 18 domain


In [2]:
np.random.seed(0)
domain = ECA(18,domain_18(600))
domain.evolve(600)

In [3]:
np.random.seed(0)
domain_states = epsilon_field(domain.get_spacetime())
domain_states.estimate_states(3,3,1, alpha = 0.05)
domain_states.filter_data()

In [4]:
print domain_states.number_of_states()


3

In [11]:
state_overlay_diagram(domain.get_spacetime(), domain_states.get_causal_field(), t_min = 10, t_max = 50, x_max = 40)



In [12]:
plcs = domain_states.PLCs()
print plcs.map_to_label('0101100010010100')


22676

In [13]:
print plcs.map_to_shape(22676)


0010100
 10001 
  101  
   0   


In [15]:
print domain_states.epsilon_map()[22676].index()


1

In [ ]:


In [10]:
print domain_states.entropy_rate('forward')
print domain_states.entropy_rate('right')
print domain_states.entropy_rate('left')


0.443796261542
0.739583703817
0.739583703817

In [ ]:


In [5]:
print len(domain_states.all_transitions())


79

In [6]:
print domain_states.nonunifilar_transitions()


[(1, 'f:0000000', 2), (1, 'r:0000', 2), (1, 'l:0000', 3), (1, 'l:0000', 2), (1, 'r:0000', 3), (1, 'f:0000000', 3), (1, 'f:0000000', 0), (2, 'f:0110001', 1), (2, 'f:1101001', 1), (2, 'f:0000011', 1), (2, 'f:1010110', 1), (2, 'f:1100111', 1), (2, 'f:1011011', 1), (2, 'f:0111100', 1), (2, 'f:0110010', 1), (2, 'f:1100100', 1), (2, 'f:1011000', 1), (2, 'f:0111111', 1), (2, 'f:0001110', 1), (2, 'f:0001101', 1), (2, 'f:1101010', 1), (2, 'f:1010101', 1), (2, 'f:0000000', 3), (2, 'f:1010101', 0), (2, 'f:1100100', 0), (2, 'f:0001101', 0), (2, 'f:0001110', 0), (2, 'f:1011000', 0), (2, 'f:1101010', 0), (2, 'f:0000000', 0), (2, 'f:0110001', 0), (2, 'f:0111100', 0), (2, 'f:1100111', 0), (2, 'f:0111111', 0), (2, 'f:0110010', 0), (2, 'f:1011011', 0), (2, 'f:1101001', 0), (2, 'f:1010110', 0), (2, 'f:0000011', 0), (3, 'f:0000000', 3), (3, 'f:1010101', 1), (3, 'f:1101010', 1), (3, 'f:0111111', 1), (3, 'f:1101010', 0), (3, 'f:0000000', 0), (3, 'f:1010101', 0), (3, 'f:0111111', 0)]

In [ ]:


In [6]:
diagram(identity.get_spacetime(),t_max = 50, x_max =50)



In [7]:
states = epsilon_field(identity.get_spacetime())
states.estimate_states(3,3,1)
states.filter_data()

In [8]:
print states.entropy_rate('forward')
print states.entropy_rate('right')
print states.entropy_rate('left')


0.991619089679
0.994375130694
0.994375130694

In [ ]: